import { Prefab, resources } from "cc";
import { $planet_Congratulation_poof$ } from "./congratulation";
import { $planet_Good_poof$ } from "./good";
import { $planet_Hint_poof$ } from "./hint";

export enum $planet_EFloat_poof$ {
	$planet_HINT_poof$,
	$planet_CONGRATULATION_poof$,
	$planet_GOOD_poof$
}

const $planet_config_poof$ = {
	[$planet_EFloat_poof$.$planet_HINT_poof$]: {
		component: $planet_Hint_poof$,
		// path: 'prefab/float/hint',
		path: 'cHJlZmFiJTJGZmxvYXQlMkZoaW50'.$planet_decodeAtoB_poof$,
		// script: './hint',
		script: 'LiUyRmhpbnQ='.$planet_decodeAtoB_poof$,
		prefab: null,
	},
	[$planet_EFloat_poof$.$planet_CONGRATULATION_poof$]: {
		component: $planet_Congratulation_poof$,
		// path: 'prefab/float/congratulation',
		path: 'cHJlZmFiJTJGZmxvYXQlMkZjb25ncmF0dWxhdGlvbg=='.$planet_decodeAtoB_poof$,
		// script: './congratulation',
		script: 'LiUyRmNvbmdyYXR1bGF0aW9u'.$planet_decodeAtoB_poof$,
		prefab: null,
	},
	[$planet_EFloat_poof$.$planet_GOOD_poof$]: {
		component: $planet_Good_poof$,
		// path: 'prefab/float/good',
		path: 'cHJlZmFiJTJGZmxvYXQlMkZnb29k'.$planet_decodeAtoB_poof$,
		// script: './good',
		script: 'LiUyRmdvb2Q='.$planet_decodeAtoB_poof$,
		prefab: null,
	},
}

export async function $planet_GetFloatPrefab_poof$(p: $planet_EFloat_poof$): Promise<Prefab> {
	let conf = $planet_config_poof$[p];
	if(!conf.prefab){
		conf.prefab = await abd.$planet_cc_poof$.$planet_loadResAsync_poof$(conf.path, Prefab, resources);
	}

	return conf.prefab;
}

export async function $planet_GetFloatComponent_poof$<F extends $planet_EFloat_poof$>(p: F): Promise<(typeof $planet_config_poof$)[F]['component']> {
	let conf = $planet_config_poof$[p];
	if(!conf.component){
		conf.component = await import(conf.script).then(m=>m.default);
	}

	return conf.component;
}

export type $planet_FloatCtor_poof$<F extends $planet_EFloat_poof$> = typeof $planet_config_poof$[F]['component'];

export type $planet_FloatIns_poof$<F extends $planet_EFloat_poof$> = InstanceType<$planet_FloatCtor_poof$<F>>;
